import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../model/cartoon_model.dart';
import '../common/api_service.dart';

class CartoonInfoController extends GetxController {
  final String cartoonId = Get.arguments['cartoonId'] ?? '';
  Rx<CartoonModel?> cartoon = Rx<CartoonModel?>(null);
  final scrollController = ScrollController();
  final tabItems = ['内容'];
  Rx<String?> coverUrl = Rx<String?>("");

  @override
  void onInit() {
    super.onInit();
    _getCartoonInfo();
  }

  _getCartoonInfo() {
    ApiService().getCartoonInfo(cartoonId, (cartoonModel) {
      cartoon.value = cartoonModel;
      var banner = cartoon.value?.banner ?? "";
      coverUrl.value = banner.isEmpty ? cartoon.value?.avatar : banner;
    }, () {});
  }
}
